package com.cg.slms.dao;

import java.util.ArrayList;
import java.util.List;

import org.mybatis.spring.SqlSessionTemplate;

import com.cg.slms.domain.Merchandise;

public class MerchandiseDao implements IMerchandiseDao{
	private SqlSessionTemplate sqlSession;
	public List<Merchandise> findMerchandise(Merchandise merchandise){
		List<Merchandise> merchandises=new ArrayList<Merchandise>();
		merchandises=sqlSession.selectList("findMerchandise", merchandise);
		return merchandises;
	}
	public SqlSessionTemplate getSqlSession() {
		return sqlSession;
	}
	public void setSqlSession(SqlSessionTemplate sqlSession) {
		this.sqlSession = sqlSession;
	}
	@Override
	public Merchandise findMerchandiseById(String id) {
		// TODO Auto-generated method stub
		Merchandise merchandise = sqlSession.selectOne("findMerchandiseById",id);
		return merchandise;
	}

	@Override
	public boolean deleteMerchandiseById(String id) {
		// TODO Auto-generated method stub
		boolean b = false;
		if (sqlSession.delete("deleteMerchandiseById",id)>0) {
			b = true;
		}
		return b;
	}
	@Override
	public boolean addMerchandise(Merchandise merchandise) {
		// TODO Auto-generated method stub
		boolean b = false;
		if (sqlSession.insert("addMerchandise",merchandise)>0) {
			b = true;
		}
		return b;
	}

	@Override
	public boolean updateMerchandise(Merchandise merchandise) {
		// TODO Auto-generated method stub
		boolean b = false;
		if (sqlSession.update("updateMerchandise",merchandise)>0) {
			b = true;
		}
		return b;
	}
}
